from pathlib import Path
import csv
import matplotlib.pyplot as plt
from datetime import datetime

path = Path('weather_data/sitka_weather_2021_simple.csv')
lines = path.read_text().splitlines()

reader = csv.reader(lines)
tt = next(reader)
# print(reader_row)
# for index,column_header in enumerate(reader_row):
#     print(index,column_header)
dates, highs, lows = [], [], []
for row in reader:
    current_date = datetime.strptime(row[2], '%Y-%m-%d')
    high = int(row[4])
    low = int(row[5])
    dates.append(current_date)
    highs.append(high)
    lows.append(low)

# print(highs)
plt.style.use('bmh')
fig, ax = plt.subplots()
ax.plot(dates, highs, color='red', alpha=0.5)
ax.plot(dates, lows, color='blue', alpha=0.5)
ax.fill_between(dates, highs, lows, color='yellow', alpha=0.3)
ax.set_title("Daily High Temperature")
ax.set_xlabel("", fontsize=13)
fig.autofmt_xdate()
ax.set_ylabel("Temperature", fontsize=12)
ax.tick_params(labelsize=14)
plt.show()
plt.savefig('weather_data/sitka_weather_2021_simple.png')
